//
//  BaseModel.m
//  项目A --半糖
//
//  Created by romana on 16/5/28.
//  Copyright © 2016年 romana. All rights reserved.
//

#import "BaseModel.h"

@implementation BaseModel

//初始化
-(instancetype)initWithDic:(NSDictionary *)dic{
    self = [super init];
    if (self) {
        //KVC赋值
        [self setValuesForKeysWithDictionary:dic];
    }
    return self;
}

//便利构造器
+(instancetype)modelWithDic:(NSDictionary *)dic{
    id m = [[[self class] alloc]initWithDic:dic];
    return m;
}

//转化
+(NSMutableArray *)transformWithArray:(NSArray *)arr{
    //创建空数组
    NSMutableArray *mArr  =[NSMutableArray array];
    //遍历传入参数
    for (NSDictionary *dic in arr) {
        //创建对象
        id m = [[self class]modelWithDic:dic];
        //添加到数组中
        [mArr addObject:m];
    }
    return mArr;
}



//KVC 赋值容错
-(void)setValue:(id)value forUndefinedKey:(NSString *)key{
    
    
    
}


@end
